package com.gk.ldj.fastdev.testcase;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.SQLException;
import java.sql.Statement;
import java.text.SimpleDateFormat;
import java.util.Date;

import com.gk.ldj.base.Configure;
import com.gk.ldj.base.Result;
import com.gk.ldj.fastdev.Db;
import com.gk.ldj.fastdev.engine.Engine;
import com.gk.ldj.fastdev.engine.EngineHelper;

public class TestDb
{
	public static void test() {
		// String name="testbatch";
		Connection conn = null;
		String dbUrl = "jdbc:oracle:thin:@192.168.90.7:1521:tdweb";
		String userName = "ctgpc";
		String password = "ctgpc";
		String serviceName="target";

		SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd hh24:mm:ss SSS");
		Date a=new Date();
		System.out.println(sdf.format(a));

		if (dbUrl != null && userName != null && password != null)
		{
			try
			{
				Class.forName("oracle.jdbc.driver.OracleDriver");
			}
			catch (ClassNotFoundException e)
			{
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
			try
			{
				conn = DriverManager.getConnection(dbUrl, userName, password);
				Statement stmt = null;
				ResultSet rs = null;
				String sql="select * from dual";
				try
				{
					stmt=conn.createStatement();
					rs = stmt.executeQuery(sql);
					if(rs.next())
					{
						System.out.println(rs.getString(1));
					}
				}
				catch (Exception ex)
				{
					ex.printStackTrace();
				}
				try
				{
					rs.close();
					stmt.close();
					rs = null;
					stmt = null;
				}
				catch (Exception ex)
				{
					ex.printStackTrace();
				}
			}
			catch (SQLException e)
			{
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
		
		a=new Date();
		System.out.println(sdf.format(a));

		a=new Date();
		System.out.println(sdf.format(a));
		try
		{
			conn.close();
			System.out.println("close");
		}
		catch (SQLException e)
		{
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
}
